package mfuny.ggongal.admin;

import javax.servlet.http.HttpSession;

import mfuny.ggongal.admin.ad.AdDao;
import mfuny.ggongal.admin.ad.AdSpecialService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class AdSpecialController {
	AdSpecialService spec;
	AdDao specClass;
	
	public AdSpecialController() throws Exception {
		spec = new AdSpecialService();
	}
	
	@RequestMapping("/specialGame.ga")
	public ModelAndView specialGame() throws Exception {
		return spec.specialGame( );
	}
	
	@RequestMapping("/regSpecialGame0.ga")
	public ModelAndView regSpecialGame0( HttpSession session ) throws Exception {
		session.removeAttribute( "specialGame" );
		return spec.regSpecialGame0( );
	}
	
	@RequestMapping("/regSpecialGame1.ga")
	public ModelAndView regSpecialGame1(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		session.setAttribute( "specialGame", adDao );
		return spec.regSpecialGame1( );
	}
	
	@RequestMapping("/regSpecialGame2.ga")
	public ModelAndView regSpecialGame2(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		specClass = (AdDao) session.getAttribute( "specialGame" );
		specClass.setT_age( adDao.getT_age( ) );
		specClass.setT_area( adDao.getT_area( ) );
		specClass.setT_job( adDao.getT_job( ) );
		specClass.setT_marry( adDao.getT_marry( ) );
		specClass.setT_sex( adDao.getT_sex( ) );
		session.setAttribute( "specialGame", specClass );
		return spec.regSpecialGame2( );
	}
	
	@RequestMapping("/regSpecialGame3.ga")
	public ModelAndView regSpecialGame3(@ModelAttribute AdDao adDao, HttpSession session ) throws Exception {
		specClass = (AdDao) session.getAttribute( "specialGame" );
		specClass.setGame_no( adDao.getGame_no( ) );
		session.setAttribute( "specialGame", specClass );
		return spec.regSpecialGame3( specClass );
	}
	
	@RequestMapping("/regSpecialGame4.ga")
	public ModelAndView regSpecialGame4( String mission, HttpSession session ) throws Exception {
		specClass = (AdDao) session.getAttribute( "specialGame" );
		specClass.setMission( mission );
		session.setAttribute( "specialGame", specClass );
		return spec.regSpecialGame4( );
	}
	
	@RequestMapping("/specialSelection.ga")
	public ModelAndView specialSelection( String days ) throws Exception {
		return spec.specialSelection( days );
	}
	
	@RequestMapping("/selectedSpec.ga")
	public ModelAndView selectedSpec( String days, String time ) throws Exception {
		return spec.selectedSpec( days, time );
	}
	
	@RequestMapping("/regSpecialGameCheck.ga")
	public ModelAndView regSpecialGameCheck( HttpSession session ) throws Exception {
		return spec.regSpecialGameCheck( session );
	}
	
	@RequestMapping("/regSpecialGameFinal.ga")
	public ModelAndView regSpecialGameFinal( HttpSession session ) throws Exception {
		spec.regSpecialGameFinal( session );
		return specialGame();
	}
	
	@RequestMapping("/detailSpecialGame.ga")
	public ModelAndView detailSpecialGame(int ad_no) throws Exception {
		return spec.detailSpecialGame(ad_no);
	}
	
	@RequestMapping("/deleteSGame.ga")
	public ModelAndView deleteSGame(int ad_no) throws Exception {
		return spec.deleteSGame(ad_no);
	}
}
